/* 
 * File:   server_SockStream.h
 * Author: max
 *
 * Created on May 21, 2013, 11:42 PM
 */

#ifndef SERVER_SOCKSTREAM_H
#define	SERVER_SOCKSTREAM_H


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h> 
#include <sys/socket.h>
#include <netinet/in.h>
#include <string>
#include "common_Excepcion.h"
#include "server_SockEndPoint.h"
#include <vector>

using namespace std;
using namespace TP;

class SockStream {

public:
    SockStream();
    
    SockStream(int pDomain, int pProtocol);
    
    virtual ~SockStream();
    
    void Iniciar () throw (Excepcion&);
    
    void Finalizar() throw (Excepcion&);
    
    void Bind(string& pPuerto, uint32_t pInAddr) throw (Excepcion&);
    
    void Listen(int pQueueLength) throw (Excepcion&);
    
    SockEndPoint* Acept () throw (Excepcion&);
    
private:
    
    void descripcionError (string &pMensaje, int pCodigoError);
    
    int _sockfd;
    struct sockaddr_in serv_addr;
    int _domain;
    int _protocol;
    vector<SockEndPoint*> _endPoints;

};

#endif	/* SERVER_SOCKSTREAM_H */

